﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Contact.aspx.cs" Inherits="Contact" MasterPageFile="~/MasterPage.master" %>
<asp:Content ID="Content1" runat="server" 
    contentplaceholderid="ContentPlaceHolder1">
    <asp:HyperLink ID="HyperLink1" runat="server" 
        NavigateUrl="~/CreateContact.aspx">Thêm liên lạc mới</asp:HyperLink>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" 
        CellPadding="3" DataKeyNames="ContactID" DataSourceID="sdsContacts" 
        ForeColor="Black" GridLines="Vertical" HorizontalAlign="Center" 
        Width="80%">
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:HyperLink ID="HyperLink2" runat="server" 
                            NavigateUrl='<%# "CreateContact.aspx?ContactID=" + Eval("ContactID") %>'>Sửa</asp:HyperLink>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:CommandField ShowDeleteButton="True" />
                <asp:BoundField DataField="FirstName" HeaderText="Họ Và Chữ Lót" 
                    SortExpression="FirstName" />
                <asp:BoundField DataField="LastName" HeaderText="Tên" 
                    SortExpression="LastName" />
                <asp:BoundField DataField="MobilePhone" HeaderText="Điện Thoại" 
                    SortExpression="MobilePhone" />
                <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
            </Columns>
            <FooterStyle BackColor="#CCCCCC" />
            <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="#CCCCCC" />
    </asp:GridView>
    <asp:SqlDataSource ID="sdsContacts" runat="server" 
        ConnectionString="<%$ ConnectionStrings:connStr %>" 
        DeleteCommand="DELETE FROM [Contact] WHERE [ContactID] = @ContactID" 
        
        SelectCommand="SELECT [ContactID], [FirstName], [LastName], [Email], [MobilePhone] FROM [Contact] WHERE ([DiaryID] = @DiaryID)">
        <SelectParameters>
            <asp:SessionParameter Name="DiaryID" SessionField="DiaryID" Type="Int32" />
        </SelectParameters>
        <DeleteParameters>
            <asp:Parameter Name="ContactID" Type="Int64" />
        </DeleteParameters>
    </asp:SqlDataSource>


</asp:Content>
